home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / wbtsort.zip / ISORT.WBT next >
Text File  |  1991-06-27  |  1KB  |  68 lines

  1. ; Example sort by Sam High
  2. ; It's as slow as mollases on ice  
  3. exclusive(@ON)
  4. array1='sam'
  5. array2='albert'
  6. array3='zoot'
  7. array4='polly'
  8. array5='frank'
  9. array6='doug'
  10. array7='lionel'
  11. array8='sam'
  12. array9='albert'
  13. array10='albert'
  14. array11='zoot'
  15. array12='polly'
  16. array13='frank'
  17. array14='doug'
  18. array15='lionel'
  19. ;debug(@ON)
  20. n=15
  21.  
  22. :Isort
  23. k=2
  24. :Passit
  25. if k > n then goto Done
  26.   hold=array%k%
  27.   i=k-1
  28.   found=@FALSE
  29. :Innerloop 
  30.   if !((i>=1) && (!found)) then goto IncK
  31.     if hold < array%i% then goto NotFound
  32.     found=@TRUE
  33.     goto Innerloop 
  34. :NotFound 
  35.     l=i+1
  36.     array%l%=array%i%
  37.     i=i-1
  38.     goto Innerloop 
  39. :IncK
  40.   l=i+1
  41.   array%l%=hold 
  42.   k=k+1
  43.   goto Passit
  44.  
  45. :Done
  46. i=2
  47. k=array1
  48. :GetIt
  49.   if i > n then goto Showit
  50.   k=strcat(k,' ',array%i%)
  51.   i=i+1
  52. goto GetIt
  53.  
  54. :Showit
  55.   x=itemselect('Sorted Array',k,' ') 
  56.  
  57. :Names
  58.   n=n+1
  59.   array%n%=askline('Isort','Enter Name','')
  60. ;  debug(@ON)
  61.   if array%n% == '' then goto Done
  62. ;  debug(@OFF)
  63.   goto Names
  64.  
  65. :Done
  66.   n=n-1
  67.   goto Isort 
  68.